﻿using System;
using NUnit.Framework;
using NUnit.Framework.Constraints;
using NUnit.Framework.SyntaxHelpers;
using Yaml.Presentation.Parsing;
using Yaml.Presentation.Tokens;

namespace Yaml.Tests.Presentation.ScannerTests {
    [TestFixture]
    public class Blocks {
        [Test]
        public void BlockStart() {
            Scanner s = Helper.CreateScanner("- \n  - \n");
            Token t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<StreamStartToken encoding='utf-8' start={0:0,0} end={0:0,0}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<BlockSequenceStartToken indent='0' start={0:0,0} end={0:0,0}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<BlockEntryToken indent='0' start={0:0,0} end={1:0,1}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<BlockSequenceStartToken indent='2' start={5:1,2} end={5:1,2}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<BlockEntryToken indent='2' start={5:1,2} end={6:1,3}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<BlockEndToken indent='0' start={8:2,0} end={8:2,0}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<BlockEndToken indent='-1' start={8:2,0} end={8:2,0}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<StreamEndToken start={8:2,0} end={8:2,0}>"));
        }

        [Test]
        public void IndentedBlock() {
            Scanner s = Helper.CreateScanner("  - \n- \n");
            Token t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<StreamStartToken encoding='utf-8' start={0:0,0} end={0:0,0}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<BlockSequenceStartToken indent='2' start={2:0,2} end={2:0,2}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<BlockEntryToken indent='2' start={2:0,2} end={3:0,3}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<BlockEndToken indent='-1' start={5:1,0} end={5:1,0}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<BlockSequenceStartToken indent='0' start={5:1,0} end={5:1,0}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<BlockEntryToken indent='0' start={5:1,0} end={6:1,1}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<BlockEndToken indent='-1' start={8:2,0} end={8:2,0}>"));
            t = s.GetToken();
            Assert.That(t.ToString(), Is.EqualTo("#<StreamEndToken start={8:2,0} end={8:2,0}>"));
        }
    }
}
